﻿namespace PowerSong.UserInterface.Tasks
    {
    using System;

    public abstract class Task
        {

        public string TaskTitle { get; private set; }

        public string TaskDescription { get; private set; }

        public delegate void ReportProgressDelegate(int percentage, string status);

        public event ReportProgressDelegate ReportProgress = null;

        public abstract void Execute();

        public abstract void HandleException(Exception ex);

        public Task(string taskTitle, string taskDescription)
            {
            this.TaskTitle = taskTitle;
            this.TaskDescription = taskDescription;
            }

        public void SetProgress(int percentage)
            {
            SetProgress(percentage, null);
            }

        public void SetProgress(int percentage, string status)
            {
            if (ReportProgress != null) ReportProgress(percentage, status);
            }

        }

    }
